package com.example.seata.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

@Configuration
public class DataSourceConfig {

    @Bean
    public DataSource dataSource1() {
        return DataSourceBuilder.create()
                .driverClassName("com.mysql.cj.jdbc.Driver")
                .url("jdbc:mysql://localhost:3306/study-spring?serverTimezone=UTC")
                .username("root")
                .password("123456")
                .type(DruidDataSource.class)
                .build();
    }

    @Bean
    public DataSource dataSource2() {
        return DataSourceBuilder.create()
                .driverClassName("com.mysql.cj.jdbc.Driver")
                .url("jdbc:mysql://localhost:3306/study-spring2?serverTimezone=UTC")
                .username("root")
                .password("123456")
                .type(DruidDataSource.class)
                .build();
    }
}
